package thread4;

public class MoneyPuter extends Thread {
	private Account ac;

	// 存钱人
	public MoneyPuter(String name, Account a) {
		super(name);
		this.ac = a;
	}

	// 策略锁
	// kafka

	@Override
	public void run() {
		while (true) {

			try {
				sleep(1500);
				synchronized (ac) {
					ac.deposit(15000);
					System.out.println(super.getName() + "存钱了，现在余额是"
							+ ac.getBalance());
					ac.notifyAll();
				}

			} catch (InterruptedException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}
		}
	}
}
